package com.arpa.oms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;


/**
 * @description
 * 出库单类型
 * @author xuyang
 * @date 2020/11/09
 **/
public enum OmsOutboundTypeEnum implements IEnum<String> {
    // 出库单类型
    SALE_OUT("SALE_OUT","销售出库"),
    SALE_RETURN("SALE_RETURN","销售退货"),
    ALLOCATION("ALLOCATION", "调拨出库"),
    DAMAGED("DAMAGED", "报损出库"),
    COLLECT("COLLECT", "领用出库"),
    COUNT_LOSS("COUNT_LOSS", "盘亏出库")
    ;

    /**
     * 值
     */
    private final String value;

    /**
     * 描述
     */
    private final String desc;

    OmsOutboundTypeEnum(final String value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static final Map<String, OmsOutboundTypeEnum> map = new HashMap();

    static {
        for(OmsOutboundTypeEnum item: values()){
            map.put(item.getValue(), item);
        }
    }

    public static OmsOutboundTypeEnum getEnumByValue(String value){
        return map.get(value);
    }

    public static String translate(String value){
        OmsOutboundTypeEnum item = getEnumByValue(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return this.desc;
    }
}
